<script type="text/javascript">
$(document).ready(function() {
	
	//cache nav
	var nav = $("#sorttour");
	
	//add indicator and hovers to submenu parents
	nav.find("li").each(function() {
		
		if ($(this).find("ul").length > 0) {
			//show subnav on hover
			$(this).mouseenter(function() {
				$(this).find("ul").stop(true, true).slideDown(300);
			});
			
			//hide submenus on exit
			$(this).mouseleave(function() {
				$(this).find("ul").stop(true, true).slideUp(300);
			});
		}
	});
	$('#theme input').click(function(){
		var baseURL ="/tour/tour/country/<?php echo $this->country; ?>/tourtypeId/<?php echo $this->tourtypeId; ?>/theme/";
		var str="";
		$('#theme input').each(function(){
			if ($(this).is(":checked"))
				str += $(this).val() + "_";
		});
		baseURL +=str;
		baseURL +="/regionId/<?php echo $this->regionId; ?>";
		window.location=baseURL;
	});
	$('input[name="region"]').click(function(){
		var baseURL ="/tour/tour/country/<?php echo $this->country; ?>/tourtypeId/<?php echo $this->country; ?>/regionId/";
		baseURL += $(this).val();
		baseURL +="/theme/<?php echo $this->themeId; ?>";
		window.location=baseURL;
	});
	var str_theme = "<?php echo $this->themeId; ?>";
	var str_themes = str_theme.split('_');
	for (var i =0 ; i < str_themes.length-1 ; i++)
	{
		$('#theme input').each(function(){
			if($(this).val()== str_themes[i] )
				$(this).attr('checked','checked');
		});
	}	
});
</script>

<div id="box_region_theme" >
	<div >
		<span>Regions :</span>
		<?php foreach ($this->region as $region): ?>
			<input name="region" type="radio" <?php if( $this->escape($region->id) == $this->regionId ) echo "checked"; ?> value="<?php echo $this->escape($region->id); ?>"  />
			<label title="<?php echo $this->escape($region->name);?>" ><?php echo substr($this->escape($region->name),0,20); if(strlen($this->escape($region->name))>30) echo("..."); ?></label>
		<?php endforeach; ?>
	</div>
	<div >
		<span>Themes :</span>
		<?php foreach ($this->theme as $theme): ?>
			<input type="checkbox" value="<?php echo $this->escape($theme->id); ?>"  />
			<label title="<?php echo $this->escape($theme->name_en);?>" ><?php echo substr($this->escape($theme->name_en),0,20); if(strlen($this->escape($theme->name_en))>30) echo("..."); ?></label>
		<?php endforeach; ?>
	</div>
</div>

<div class="clear" ></div>

<div id="sorttour" >
		<ul>
			<li><a href="" > Newest </a></li>
			<li><a href="" > Best Choice  </a></li>
			<li><a href="" > Most Popular  </a></li>
			<li><a ><?php if($this->tourtypeId == 0) echo "Tour Type"; elseif ($this->tourtypeId == 1) echo " Sort Tours " ; else echo " Package Tours "  ?>  </a>
				<ul style="width: 100px" >
					<li><a> Sort Tours </a></li>
					<li><a> Package Tours </a></li>
				</ul>
			</li>
			<li><a  > Length  </a>
				<ul style="width: 130px" >
					<li><a> 1-2 Days </a></li>
					<li><a> 3-4 Days </a></li>
					<li><a> 5-7 Days </a></li>
					<li><a> 8-10 Days </a></li>
					<li><a> More than 11 Days </a></li>
				</ul>
			</li>
		</ul>
</div>

<div class="clear" ></div>

<div id="listtour" >
<?php foreach ($this->tours as $tours): ?>
<div id="touritem" >
	<div class="touritem-right" >
		<img src="/files/images/tour/<?php echo $this->escape($tours['image']); ?>"/>
		<span><a href="<?php echo $this->url(array('country' => $this->countryname,'tourId'=>$tours['id'],'nametour' => $tours['alias']), 'detailshorttour') ?>" >More Details...</a></span>
	</div>
	<div class="touritem-left" >
		<div><label><?php echo $this->escape($tours['name']);?></label></div>
		<div><span><?php echo $this->escape($tours['length_day']);?> Days / <?php echo $this->escape($tours['length_night']);?> Night</span></div>
		<div><span><?php echo substr($this->escape($tours['intro']),0,300); if(strlen($this->escape($tours['intro']))>300) echo("..."); ?></span></div>
	</div>
</div>	
<?php endforeach; ?>
</div>
<div style="float: right;margin-right: 10px;width: 200px" id="paginator" >
<?php echo $this->paginationControl($this->tours, 'Elastic', 'paginator.phtml');?>
</div>
